<template>

	<view class="">



		<image src="../../static/downloadbj.png" style="width: 100%;height: 100%;	" mode="widthFix" @tap="getApk">
			<cover-view class="banner_title">


				<!-- <text style="color: #0D56D9;font-size: 24px;font-weight: bold;">{{amount}}</text> -->

			</cover-view>


		</image>
		<!-- <text style="color: #333333; font-size: 20px;font-weight: 500;margin-top: 30px;">您的借款申请已提交</text> -->
		<!-- <text style="color: #C53E3E;margin-top: 10px;font-size: 18px;">请耐心等待线下贷款专员联系您</text> -->


		<!-- 	<view class="" style="background-color: #F3F7FA;height: 500px;">
			<view class="" style="padding: 16px 40px 128px 40px;height: 80px;">
				<text style="color: #8B8B8B;font-size: 13px;">为保障您的资金安全，请不要相信任何在放款前需要支付费用的信息、邮件、电话等，并注意保护您的个人隐私信息。
					如您需要帮助，请及时联系APP内在线客服。</text>
			</view>


			<view class="" @click="getApk" style="width: 100%;height: 90px;">
				<image src="../../static/xiazaibutton.png" mode="aspectFit"
					style="position: fixed;width: 100%;top: 520px;left: 0;"></image>

			</view>

		</view> -->

		<view class="mask" v-if="showmask">
			<view class="" style="width: 100%;height: 700px;text-align: center;margin: 0;display: flex;	flex-direction: column;
			
			align-items: center;
			justify-content: center;">
				<text style="color: #FFFFFF;font-size: 20px;">点击右上角···按钮 </text> <text
					style="color: #FFFFFF;font-size: 20px; ">选择在浏览器中打开下载APP </text>
			</view>

		</view>






	</view>


</template>

<script>
	import Mask from '../mask/mask.vue';
	export default {
		components: {
			Mask
		},
		data() {

			return {

				andoridUrl: 'https://source.renxinhua.cn/apk/bbd.apk',
				channelCode: '',
				showmask: false,
				amount: ''
			}
		},

		onLoad() {
			// this.getAndoridUrl().then(()=>);

			this.isWeiXinLogin();
			// this.shunxu();

			// this.getApk();

			var s = this.randomRange(2, 10)
			this.amount = s + '0,' + '000'

		},
		onReady() {
			// this.getApk();
		},
		methods: {
			randomRange(min, max) { // min最小值，max最大值

				return Math.floor(Math.random() * (max - min)) + min;

			},
			async shunxu() {
				// await this.getAndoridUrl();

				this.getApk()
			},

			//判断是否微信登陆
			isWeiXinLogin() {
				var ua = window.navigator.userAgent.toLowerCase();
				console.log(
					ua
				); //mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
				if (ua.match(/MicroMessenger/i) == 'micromessenger') {
					this.showmask = true;
					this.count(4)
					return true;

				} else {
					return false;
				}
			},
			async getAndoridUrl() {
				const res = await this.$myRequest({
					url: '/mkt/open/release/url',
					method: 'get',


				})
				this.andoridUrl = res.data.retData[0].appUrl
				// console.log(this.andoridUrl)

			},
			async getApk() {


				let platform = uni.getSystemInfoSync().platform;
				// await this.save()
				var ch = uni.getStorageSync('channelCode')
				if (platform == 'ios' && ch == "NT6UVL") {
					this.copyText('https://apps.apple.com/cn/app/%E4%BB%BB%E4%BF%A1%E8%8A%B1/id1641880064')
					return;
				}
				if (platform == 'android' && ch == "NT6UVL") {
					this.copyText('https://source.renxinhua.cn/apk/rxh.apk')
					return;
				}


				// console.log(platform)
				this.count(1)
				if (platform == 'android') {
					try {


						uni.showToast({
							title: '正在下载。。。',
							icon: 'loading'
						})
						window.location.href = this.andoridUrl;
					} catch (e) {
						alert("error:" + e.message);
					}

				} else {
					try {
						uni.showToast({
							title: '正在下载。。。',
							icon: 'loading'
						})
						window.location.href =
							'https://apps.apple.com/cn/app/%E4%BB%BB%E4%BF%A1%E8%8A%B1/id1641880064';

					} catch (e) {
						alert("error:" + e.message);
					}
				}




			},
			copyText(text) {
				// console.log(text);
				// #ifdef H5
				this.$copyText(text).then(
					res => {
						uni.showToast({
							title: '复制成功，打开浏览器粘贴领取额度',
							duration: 5000
						})
					}
				)
				// #endif
				// #ifndef H5
				uni.setClipboardData({
					data: text,
					success: () => {
						uni.showToast({
							title: '复制成功，打开浏览器粘贴领取额度',
							duration: 5000
						})
					}
				})
				// #endif
			},


			getRequestParams() {
				let url = location.href;
				let requestParams = {};
				if (url.indexOf("?") !== -1) {
					let str = url.substr(url.indexOf("?") + 1); //截取?后面的内容作为字符串
					// console.log(str, '?后面的内容');
					let strs = str.split("&"); //将字符串内容以&分隔为一个数组
					// console.log(strs, '以&切割的数组');
					for (let i = 0; i < strs.length; i++) {
						requestParams[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
						// 将数组元素中'='左边的内容作为对象的属性名，'='右边的内容作为对象对应属性的属性值
					}
				}
				// console.log(theRequest, "处理后的对象");
				return requestParams;
			},
			count(e) {
				this.$myRequest({
					url: 'api/sys/count',
					method: 'post',
					data: {
						'operType': e,

					}

				})
			}


		},


	}
</script>


<style lang="scss">
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: #000000;
		opacity: 0.7;
		z-index: 99;
	}


	.banner_title {
		position: absolute;

		top: 480rpx;
		left: 390rpx;
	}

	.btm {

		width: 650rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	cover-view {
		margin: 50rpx;
		display: flex;
		flex-direction: column;
		align-items: auto;
	}
</style>
